<?php

/**
 * kcDoctrineRawSql
 *
 * @package    flexiwik
 * @subpackage lib.model
 * @author     Pedro Nilton Olivera Chamochumbi <poliverach@gmail.com>
 */
class kcDoctrineRawSql extends Doctrine_RawSql
{
  public function appendFrom($from)
  {
    return $this->_addDqlQueryPart('from', $from, true);
  }
  public function fetchOne($params = array(), $hydrationMode = null)
  {
    $collection = $this->execute($params, $hydrationMode);

    if (count($collection) === 0)
    {
      return false;
    }

    if ($collection instanceof Doctrine_Collection)
    {
      return $collection->getFirst();
    }
    else if (is_array($collection))
    {
      return array_shift($collection);
    }

    return false;
  }
}
